package com.dianshang.springdataredis;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import redis.clients.jedis.Jedis;

/**
 * Redis基本语法入门(String,List,Hash,Set,ZSet)
 */
@RunWith(SpringJUnit4ClassRunner.class) // Spring整合Redis的核心类
@ContextConfiguration(locations = "classpath:applicationContext-redis.xml") // 上下文配置文件
public class RedisDemo {

    @Test
    public void zhaoyu(){
        Jedis jedis = new Jedis("127.0.0.1", 6379);
        // String类型
        jedis.set("user1","123");
        // List类型
        jedis.lpush("user2","456");
        // Hash类型
        jedis.hset("user3","赵宇","789"); // field == 变量.get字段+""
        // Set类型
        jedis.sadd("user4","{name:'赵宇',age:19,sex:'男'}");
        // ZSet类型
        jedis.zadd("user5",1,"{name:'祁丽娜',age:20,sex:'女'}");
    }

}